package leetcode
/*
 * @lc app=leetcode.cn id=48 lang=golang
 *
 * [48] 旋转图像
 */

import "fmt"

// @lc code=start
func rotate2(matrix [][]int) {
	n := len(matrix)
	for i := 0; i < n/2; i++ {
		for j := i; j < n-1-i; j++ {
			matrix[i][j], matrix[j][n-1-i], matrix[n-1-i][n-1-j], matrix[n-1-j][i] =
				matrix[n-1-j][i], matrix[i][j], matrix[j][n-1-i], matrix[n-1-i][n-1-j]
		}
	}
}

func rotate(matrix [][]int) {
	n := len(matrix)
	for j := range matrix {
		for i := 0; i < n/2; i++ {
			matrix[i][j], matrix[n-1-i][j] = matrix[n-1-i][j], matrix[i][j]
		}
	}
	for i := range matrix {
		for j := i + 1; j < n; j++ {
			matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
		}
	}
}

func printMatrix(matrix [][]int) {
	for _, r := range matrix {
		fmt.Println(r)
	}
	fmt.Println()
}

// @lc code=end
